<?php
import("@.Org.PaymentTool");



class PaymentAction extends CommentAction{
	
	public function _initialize(){
		parent::_initialize();
		$param          =   $this->_get('_URL_');
		$controller     =   $param[0];
		$action         =   $param[1];
		//language
		$lang            =    L($action);  		
		$manage          =    L('manage');
		
		$this->assign("manage",$manage);
		$this->assign("current",$lang);
		$this->assign("lang",$lang);
	}
	
	public function pay_list(){
		/* 查询数据库中启用的支付方式 */
	    $pay_list 		= 	array();
	    $sql 			= 	"SELECT * FROM " . 'ybr_payment' . " WHERE enabled = '1' ORDER BY pay_order";
	    $res 			= 	M()->query($sql);
	    
	    foreach($res as $row){
	    	$pay_list[$row['pay_code']] = $row;
	    }
	    
	    /* 取得插件文件中的支付方式 */
	    $modules = read_modules(VENDOR_PATH . 'payment');
	    for ($i = 0; $i < count($modules); $i++)
	    {
	        $code = $modules[$i]['code'];
	        $modules[$i]['pay_code'] = $modules[$i]['code'];
	        /* 如果数据库中有，取数据库中的名称和描述 */
	        if (isset($pay_list[$code]))
	        {
	            $modules[$i]['name'] = $pay_list[$code]['pay_name'];
	            $modules[$i]['pay_fee'] =  $pay_list[$code]['pay_fee'];
	            $modules[$i]['is_cod'] = $pay_list[$code]['is_cod'];
	            $modules[$i]['desc'] = $pay_list[$code]['pay_desc'];
	            $modules[$i]['pay_order'] = $pay_list[$code]['pay_order'];
	            $modules[$i]['install'] = '1';
	        }
	        else
	        {
	            $modules[$i]['name'] = $_LANG[$modules[$i]['code']];
	            if (!isset($modules[$i]['pay_fee']))
	            {
	                $modules[$i]['pay_fee'] = 0;
	            }
	            $modules[$i]['desc'] = $_LANG[$modules[$i]['desc']];
	            $modules[$i]['install'] = '0';
	        }
	       if ($modules[$i]['pay_code'] == 'tenpayc2c')
	       {
	            $tenpayc2c = $modules[$i];
	       }
	    }
	
	    //include_once(ROOT_PATH.'includes/lib_compositor.php');
		
	    $this->assign('modules', $modules);
	    $this->assign('tenpayc2c', $tenpayc2c);
		$this->display();
	}
	
	
	
	
	
	
	
	
}

